package cc.chinagps.gateway.unit.eg.upload.cmds;

import cc.chinagps.gateway.client.TransferDeviceManager;
import cc.chinagps.gateway.log.LogManager;
import cc.chinagps.gateway.unit.UnitServer;
import cc.chinagps.gateway.unit.UnitSocketSession;
import cc.chinagps.gateway.unit.eg.pkg.EGPackage;
import cc.chinagps.gateway.unit.eg.upload.bean.EGAlarmInfo;
import cc.chinagps.gateway.unit.eg.util.EGUploadUtil;
import cc.chinagps.gateway.util.DateTimeUtil;
import org.apache.log4j.Logger;

public class Cmd06 extends CheckLoginHandler {
    private Logger logger_debug = Logger.getLogger(LogManager.LOGGER_NAME_DEBUG);

    @Override
    public boolean handlerPackageSessionChecked(EGPackage pkg, UnitServer server, UnitSocketSession session)
            throws Exception {
        String callLetter = session.getUnitInfo().getCallLetter();
        int pos = 0;
        byte[] data = pkg.getData();
        EGAlarmInfo egAlarm = new EGAlarmInfo();
        egAlarm.parse(data, pos);
        egAlarm.getAlarmTypeList().add(318);
        logger_debug.debug("[EG][Cmd06][" + callLetter + "]recv egAlarm:" + egAlarm);
        EGUploadUtil.handleAlarmInfo(pkg, server, session, egAlarm);
        TransferDeviceManager.instance.clientSendTerminalRemovedAlarm(callLetter, egAlarm, pkg);
        return true;
    }
}